<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div th:fragment="pageFragment" style="width: 70%;text-align: center;margin: auto">

    <th:block th:if="${pageInfo.hasPreviousPage}">
        <a th:href="@{'/index?pageNum=1'}">
            <span style="display: inline-block;width: 80px;height: 20px;text-align: center;border: 1px solid #ccc;">第一页</span>
        </a>
        <th:block th:if="${pageInfo.pageNum<6}">
            <a th:href="@{'/index?pageNum='+${pageInfo.prePage}}">
                <span style="display: inline-block;width: 80px;height: 20px;text-align: center;border: 1px solid #ccc;">上一页</span>
            </a>
        </th:block>
        <th:block th:unless="${pageInfo.pageNum<6}">
            <a th:href="@{'/index?pageNum='+${pageInfo.prePage}}">
                <span style="display: inline-block;width: 80px;height: 20px;text-align: center;border: 1px solid #ccc;">上一页</span>
            </a>
            ......
        </th:block>
    </th:block>

    <th:block th:each="index:${pageInfo.navigatepageNums}">
        <a th:if="${pageInfo.pageNum==index}">
            <span th:text="${index}" style="display: inline-block;width: 20px;height: 20px;text-align: center;border: 1px solid #ccc; background-color: #ccc"></span>
        </a>
        <a th:unless="${pageInfo.pageNum==index}" th:href="@{'/index?pageNum='+${index}}">
            <span th:text="${index}" style="display: inline-block;width: 20px;height: 20px;text-align: center;border: 1px solid #ccc;"></span>
        </a>
    </th:block>

    <th:block th:if="${pageInfo.hasNextPage}">
        <th:block th:if="${pageInfo.pageNum<((pageInfo.pages)-5)}">
            ......
            <a th:href="@{'/index?pageNum='+${pageInfo.nextPage}}">
                <span style="display: inline-block;width: 80px;height: 20px;text-align: center;border: 1px solid #ccc;">下一页</span>
            </a>
        </th:block>
        <th:block th:unless="${pageInfo.pageNum<((pageInfo.pages)-5)}">
            <a th:href="@{'/index?pageNum='+${pageInfo.nextPage}}">
                <span style="display: inline-block;width: 80px;height: 20px;text-align: center;border: 1px solid #ccc;">下一页</span>
            </a>
        </th:block>
        <a th:href="@{'/index?pageNum='+${pageInfo.pages}}">
            <span style="display: inline-block;width: 80px;height: 20px;text-align: center;border: 1px solid #ccc;">最后一页</span>
        </a>
    </th:block>

</div>

</body>
</html>